package viv.karaoke.book;

import java.util.List;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class FavouriteFragment extends Fragment
{
	private ListView lvProfile;
	private ListView lvSong;
	
	@Override
	public View onCreateView( LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState )
	{	
		View view = inflater.inflate(R.layout.favourite, container, false);
		
		lvProfile =  (ListView) view.findViewById(R.id.lvProfile);
		lvSong =  (ListView) view.findViewById(R.id.lvSong);
		
		return view;
	}
	
	@Override
	  public void onActivityCreated(Bundle savedInstanceState) {
	    super.onActivityCreated(savedInstanceState);
	    
	    String[] favouriteNames = new String[] { "Android", "iPhone", "WindowsMobile",
				  "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
				  "Linux", "OS/2", "Android", "iPhone", "WindowsMobile",
				  "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
				  "Linux", "OS/2" };
	    
	    String[] songNames = new String[] { "My heart will go on", "iPhone", "WindowsMobile",
				  "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
				  "Linux", "OS/2", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", };
		
	    Activity activity = getActivity();
	    
	    if (activity != null) {
	    	
//	    	View favouriteHeaderList = (View)activity.getLayoutInflater().inflate(viv.karaoke.book.R.layout.profile_listview_header_row, null);
	    	
	    	ProfileAdapter profileAdapter = new ProfileAdapter(activity, viv.karaoke.book.R.layout.profile_listview_item_row, favouriteNames);
	    		
//	    	lvProfile.addHeaderView(favouriteHeaderList);
	    	lvProfile.setAdapter(profileAdapter);
	    	
//	    	ProfileAdapter songAdapter = new ProfileAdapter(activity, viv.karaoke.book.R.layout.profile_listview_item_row, songNames);
	    	SongDataSource songDataSource = new SongDataSource(activity);
	    	songDataSource.open();
	    	
	    	List<song> songList = songDataSource.getAllSongs("", 0);
	    	
	    	SongAdapter songAdapter = new SongAdapter(activity, songList);
	    	
	    	lvSong.setAdapter(songAdapter);
	    }
		//ListView listView =  (ListView) getActivity().findViewById(R.id.lvProfile);
		//listView.setAdapter(new ProfileAdapter(this.getActivity(), values));
		
	    //ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
	    //    android.R.layout.simple_list_item_1, values);
	    
	    //setListAdapter(new ArrayAdapter<String>(getActivity().getApplicationContext(),
        //        android.R.layout.simple_list_item_1, values));
	    
	    //setListAdapter(adapter);
	  }
}
